<!--头部公共部分-->
{include file="common/header" /}
<div style="padding:15px;font-size: 12px;">
    <div class="layui-tab">
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form" action="" method="POST">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">*</span>课次</label>
                        <div class="layui-input-inline" style="width: 520px;">
                            <input type="number" name="class_times" lay-verify="number" value="{$schedule.class_times}" placeholder="请输入课次" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span style="color: red;">*</span>章节</label>
                        <div class="layui-input-inline" style="width: 520px;">
                            <input type="text" name="class_chapter" lay-verify="required" value="{$schedule.class_chapter}"  placeholder="请输入章节" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label"><span style="color: red;">*</span>上课内容</label>
                        <div class="layui-input-block">
                            <textarea placeholder="请输入内容,500字符以内" lay-verify="required" name="class_content" class="layui-textarea">{$schedule.class_content}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="course_id" value="{$course_id}">
                            <input type="hidden" name="id" value="{$schedule.id}">
                            <input class="layui-btn" lay-submit lay-filter="wxsubmit" id="sub" value="提交" readonly>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--底部公共部分-->
{include file="common/footer" /}


<script>
    layui.use(['jquery','element','form','layer'], function(){
        var $ = layui.jquery,
            layer = layui.layer,
            element = layui.element,
            form = layui.form;

        form.on('submit(wxsubmit)', function (data) {
            let field = data.field;
            let course_id = $("#course_id").val();
            $.ajax({
                type: 'post',
                url: '{:url("Schedule/edit")}',
                data: field,
                success: function (result) {
                    layer.msg(result.msg);
                    if (result.code === 1) {
                        setTimeout(function () {
                            let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            // parent.location.href = '{:url("Schedule/lists")}?course_id=' + course_id
                            parent.location.reload();
                        }, 2000);
                    }
                }
            });
        });
    });
</script>
